package medium;

import java.util.*;

/**
 * 2225. 找出输掉零场或一场比赛的玩家
 *
 * @author lanran
 * @date 2024/5/22 0:08
 **/
public class 找出输掉零场或一场比赛的玩家_2225 {
    class Solution {
        public List<List<Integer>> findWinners(int[][] matches) {
            Map<Integer, Integer> map = new HashMap<>();
            for (int[] m : matches) {
                if (!map.containsKey(m[0])) {
                    map.put(m[0], 0);
                }
                map.merge(m[1], 1, Integer::sum);
            }
            List<List<Integer>> ans = Arrays.asList(new ArrayList<>(), new ArrayList<>());
            for (Integer key : map.keySet()) {
                if (map.get(key) < 2) {
                    ans.get(map.get(key)).add(key);
                }
            }
            ;
            Collections.sort(ans.get(0));
            Collections.sort(ans.get(1));
            return ans;
        }
    }
}
